#pragma once

#include "BufferedSocket.h"
#include "DateTime.h"
#include "Singleton.h"
#include "Timer.h"

namespace Core
{
	class Synchronizer : public Singleton<Synchronizer>, public Timer
	{
		friend class Singleton<Synchronizer>;

	private:
		unsigned long m_TimeStamp;
		std::map<unsigned long, DateTime> m_Times;
		InternetAddress m_BroadcastAddress;
		RawData m_RawData;
		BufferedSocket m_Socket;

		Synchronizer();
		void ExecuteByInterval();

	public:
		void Start(unsigned short p_Port);
		bool IsPrimary();
		unsigned char GetLevel();
		void SetAsStandby();
	};
}
